package gr.unipi.mscd1;

import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JTextArea;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.data.time.Second;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.snmp4j.PDU;
import org.snmp4j.event.ResponseEvent;
import org.snmp4j.event.ResponseListener;
import org.snmp4j.smi.OID;
import com.jgoodies.forms.factories.DefaultComponentFactory;
import java.awt.Font;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
import java.awt.FlowLayout;
import javax.swing.JScrollPane;
import javax.swing.BoxLayout;

public class IfInfoDetailsPanel extends JPanel implements SnmpValuesListener {
	
	private static final long serialVersionUID = 1L;
	private InterfaceInfoDetails infoDet;
	
	IfInfoDetailsPanel thispnl;
	private JPanel pnlGen;
	private JPanel pnlDetTitle;
	private JLabel lblDetTitle;
	private JPanel pnlGenInfo;
	private JLabel lblCurrTIn;
	private JTextArea txtCurrTIn;
	private JLabel lblCurrTOut;
	private JTextArea txtCurrTOut;
	private JLabel lblCurrPIn;
	private JTextArea txtCurrPIn;
	private JLabel lblCurrPOut;
	private JTextArea txtCurrPOut;
	private JLabel lblCurrUtil;
	private JTextArea txtCurrUtil;
	
	private JLabel lblCurrentStats;
	private JLabel lblAvgStats;
	private JLabel lblAvgTIn;
	private JLabel lblAvgPIn;
	private JLabel lblAvgUtil;
	private JLabel lblAvgTOut;
	private JLabel lblAvgPOut;
	private JTextArea txtAvgTIn;
	private JTextArea txtAvgPIn;
	private JTextArea txtAvgUtil;
	private JTextArea txtAvgTOut;
	private JTextArea txtAvgPOut;
	
	private JFreeChart throughputChart;
	private JFreeChart packetsChart;
	
	private TimeSeries throughputIn;
	private TimeSeries throughputOut;
	private TimeSeries packetsIn;
	private TimeSeries packetsOut;
	
	
	public IfInfoDetailsPanel(SimpleSnmpClient client, int ifId, int ifSpeed) {
		thispnl = this;
		infoDet = new InterfaceInfoDetails(client, ifSpeed, ifId + "");
		setBackground(Color.WHITE);
		setLayout(new BorderLayout(0, 0));
		
		pnlCharts = new JPanel();
		pnlCharts.setBackground(Color.WHITE);
		add(pnlCharts, BorderLayout.CENTER);
		
		pnlGen = new JPanel();
		pnlGen.setBackground(Color.WHITE);
		add(pnlGen, BorderLayout.NORTH);
		pnlGen.setLayout(new BorderLayout(0, 0));
		
		pnlDetTitle = new JPanel();
		pnlDetTitle.setBackground(Color.WHITE);
		pnlGen.add(pnlDetTitle, BorderLayout.NORTH);
		
		lblDetTitle = DefaultComponentFactory.getInstance().createTitle("");
		lblDetTitle.setFont(new Font("Tahoma", Font.BOLD, 15));
		pnlDetTitle.add(lblDetTitle);
		
		pnlGenInfo = new JPanel();
		pnlGenInfo.setBackground(Color.WHITE);
		pnlGen.add(pnlGenInfo, BorderLayout.CENTER);
		GridBagLayout gbl_pnlGenInfo = new GridBagLayout();
		gbl_pnlGenInfo.columnWidths = new int[] {100, 80, 100, 80, 100, 0, 80};
		gbl_pnlGenInfo.rowHeights = new int[] {20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 20, 30, 30, 30, 30, 20, 30, 20, 20, 20, 20, 20};
		gbl_pnlGenInfo.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
		gbl_pnlGenInfo.rowWeights = new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
		pnlGenInfo.setLayout(gbl_pnlGenInfo);
		
		lblCurrentStats = new JLabel("Current interface stats");
		lblCurrentStats.setFont(new Font("Tahoma", Font.BOLD, 13));
		GridBagConstraints gbc_lblCurrentStats = new GridBagConstraints();
		gbc_lblCurrentStats.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrentStats.gridx = 0;
		gbc_lblCurrentStats.gridy = 0;
		pnlGenInfo.add(lblCurrentStats, gbc_lblCurrentStats);
		
		lblCurrTIn = new JLabel("Throughput in (per second):");
		GridBagConstraints gbc_lblCurrTIn = new GridBagConstraints();
		gbc_lblCurrTIn.anchor = GridBagConstraints.EAST;
		gbc_lblCurrTIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrTIn.gridx = 0;
		gbc_lblCurrTIn.gridy = 1;
		pnlGenInfo.add(lblCurrTIn, gbc_lblCurrTIn);
		
		txtCurrTIn = new JTextArea();
		txtCurrTIn.setEditable(false);
		GridBagConstraints gbc_txtCurrTIn = new GridBagConstraints();
		gbc_txtCurrTIn.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCurrTIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrTIn.gridx = 1;
		gbc_txtCurrTIn.gridy = 1;
		pnlGenInfo.add(txtCurrTIn, gbc_txtCurrTIn);
		
		lblCurrTOut = new JLabel("Throughput out (per second):");
		GridBagConstraints gbc_lblCurrTOut = new GridBagConstraints();
		gbc_lblCurrTOut.anchor = GridBagConstraints.EAST;
		gbc_lblCurrTOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrTOut.gridx = 2;
		gbc_lblCurrTOut.gridy = 1;
		pnlGenInfo.add(lblCurrTOut, gbc_lblCurrTOut);
		
		txtCurrTOut = new JTextArea();
		txtCurrTOut.setEditable(false);
		GridBagConstraints gbc_txtCurrTOut = new GridBagConstraints();
		gbc_txtCurrTOut.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCurrTOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrTOut.gridx = 3;
		gbc_txtCurrTOut.gridy = 1;
		pnlGenInfo.add(txtCurrTOut, gbc_txtCurrTOut);
		
		lblCurrThroughSum = new JLabel("Throughput sum (per second):");
		GridBagConstraints gbc_lblCurrThroughSum = new GridBagConstraints();
		gbc_lblCurrThroughSum.anchor = GridBagConstraints.EAST;
		gbc_lblCurrThroughSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrThroughSum.gridx = 4;
		gbc_lblCurrThroughSum.gridy = 1;
		pnlGenInfo.add(lblCurrThroughSum, gbc_lblCurrThroughSum);
		
		txtCurrThroughSum = new JTextArea();
		txtCurrThroughSum.setEditable(false);
		GridBagConstraints gbc_txtCurrThroughSum = new GridBagConstraints();
		gbc_txtCurrThroughSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrThroughSum.fill = GridBagConstraints.BOTH;
		gbc_txtCurrThroughSum.gridx = 5;
		gbc_txtCurrThroughSum.gridy = 1;
		pnlGenInfo.add(txtCurrThroughSum, gbc_txtCurrThroughSum);
		
		lblCurrPIn = new JLabel("Packets in (per second):");
		GridBagConstraints gbc_lblCurrPIn = new GridBagConstraints();
		gbc_lblCurrPIn.anchor = GridBagConstraints.EAST;
		gbc_lblCurrPIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrPIn.gridx = 0;
		gbc_lblCurrPIn.gridy = 2;
		pnlGenInfo.add(lblCurrPIn, gbc_lblCurrPIn);
		
		txtCurrPIn = new JTextArea();
		txtCurrPIn.setEditable(false);
		GridBagConstraints gbc_txtCurrPIn = new GridBagConstraints();
		gbc_txtCurrPIn.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCurrPIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrPIn.gridx = 1;
		gbc_txtCurrPIn.gridy = 2;
		pnlGenInfo.add(txtCurrPIn, gbc_txtCurrPIn);
		
		lblCurrPOut = new JLabel("Packets out (per second):");
		GridBagConstraints gbc_lblCurrPOut = new GridBagConstraints();
		gbc_lblCurrPOut.anchor = GridBagConstraints.EAST;
		gbc_lblCurrPOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrPOut.gridx = 2;
		gbc_lblCurrPOut.gridy = 2;
		pnlGenInfo.add(lblCurrPOut, gbc_lblCurrPOut);
		
		txtCurrPOut = new JTextArea();
		txtCurrPOut.setEditable(false);
		GridBagConstraints gbc_txtCurrPOut = new GridBagConstraints();
		gbc_txtCurrPOut.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCurrPOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrPOut.gridx = 3;
		gbc_txtCurrPOut.gridy = 2;
		pnlGenInfo.add(txtCurrPOut, gbc_txtCurrPOut);
		
		lblCurrPktsSum = new JLabel("Packets sum (per second):");
		GridBagConstraints gbc_lblCurrPktsSum = new GridBagConstraints();
		gbc_lblCurrPktsSum.anchor = GridBagConstraints.EAST;
		gbc_lblCurrPktsSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrPktsSum.gridx = 4;
		gbc_lblCurrPktsSum.gridy = 2;
		pnlGenInfo.add(lblCurrPktsSum, gbc_lblCurrPktsSum);
		
		txtCurrPktsSum = new JTextArea();
		txtCurrPktsSum.setEditable(false);
		GridBagConstraints gbc_txtCurrPktsSum = new GridBagConstraints();
		gbc_txtCurrPktsSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrPktsSum.fill = GridBagConstraints.BOTH;
		gbc_txtCurrPktsSum.gridx = 5;
		gbc_txtCurrPktsSum.gridy = 2;
		pnlGenInfo.add(txtCurrPktsSum, gbc_txtCurrPktsSum);
		
		lblCurrDiscIn = new JLabel("Discards in (per second):");
		GridBagConstraints gbc_lblCurrDiscIn = new GridBagConstraints();
		gbc_lblCurrDiscIn.anchor = GridBagConstraints.EAST;
		gbc_lblCurrDiscIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrDiscIn.gridx = 0;
		gbc_lblCurrDiscIn.gridy = 3;
		pnlGenInfo.add(lblCurrDiscIn, gbc_lblCurrDiscIn);
		
		txtCurrDiscIn = new JTextArea();
		txtCurrDiscIn.setEditable(false);
		GridBagConstraints gbc_txtCurrDiscIn = new GridBagConstraints();
		gbc_txtCurrDiscIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrDiscIn.fill = GridBagConstraints.BOTH;
		gbc_txtCurrDiscIn.gridx = 1;
		gbc_txtCurrDiscIn.gridy = 3;
		pnlGenInfo.add(txtCurrDiscIn, gbc_txtCurrDiscIn);
		
		lblCurrDiscOut = new JLabel("Discards out (per second):");
		GridBagConstraints gbc_lblCurrDiscOut = new GridBagConstraints();
		gbc_lblCurrDiscOut.anchor = GridBagConstraints.EAST;
		gbc_lblCurrDiscOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrDiscOut.gridx = 2;
		gbc_lblCurrDiscOut.gridy = 3;
		pnlGenInfo.add(lblCurrDiscOut, gbc_lblCurrDiscOut);
		
		txtCurrDiscOut = new JTextArea();
		txtCurrDiscOut.setEditable(false);
		GridBagConstraints gbc_txtCurrDiscOut = new GridBagConstraints();
		gbc_txtCurrDiscOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrDiscOut.fill = GridBagConstraints.BOTH;
		gbc_txtCurrDiscOut.gridx = 3;
		gbc_txtCurrDiscOut.gridy = 3;
		pnlGenInfo.add(txtCurrDiscOut, gbc_txtCurrDiscOut);
		
		lblCurrDiscSum = new JLabel("Discards sum (per second):");
		GridBagConstraints gbc_lblCurrDiscSum = new GridBagConstraints();
		gbc_lblCurrDiscSum.anchor = GridBagConstraints.EAST;
		gbc_lblCurrDiscSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrDiscSum.gridx = 4;
		gbc_lblCurrDiscSum.gridy = 3;
		pnlGenInfo.add(lblCurrDiscSum, gbc_lblCurrDiscSum);
		
		txtCurrDiscSum = new JTextArea();
		txtCurrDiscSum.setEditable(false);
		GridBagConstraints gbc_txtCurrDiscSum = new GridBagConstraints();
		gbc_txtCurrDiscSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrDiscSum.fill = GridBagConstraints.BOTH;
		gbc_txtCurrDiscSum.gridx = 5;
		gbc_txtCurrDiscSum.gridy = 3;
		pnlGenInfo.add(txtCurrDiscSum, gbc_txtCurrDiscSum);
		
		lblCurrDiscInPerc = new JLabel("Discards in (%):");
		GridBagConstraints gbc_lblCurrDiscInPerc = new GridBagConstraints();
		gbc_lblCurrDiscInPerc.anchor = GridBagConstraints.EAST;
		gbc_lblCurrDiscInPerc.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrDiscInPerc.gridx = 0;
		gbc_lblCurrDiscInPerc.gridy = 4;
		pnlGenInfo.add(lblCurrDiscInPerc, gbc_lblCurrDiscInPerc);
		
		txtCurrDiscInPerc = new JTextArea();
		txtCurrDiscInPerc.setEditable(false);
		GridBagConstraints gbc_txtCurrDiscInPerc = new GridBagConstraints();
		gbc_txtCurrDiscInPerc.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrDiscInPerc.fill = GridBagConstraints.BOTH;
		gbc_txtCurrDiscInPerc.gridx = 1;
		gbc_txtCurrDiscInPerc.gridy = 4;
		pnlGenInfo.add(txtCurrDiscInPerc, gbc_txtCurrDiscInPerc);
		
		lblCurrDiscOutPerc = new JLabel("Discards out (%):");
		GridBagConstraints gbc_lblCurrDiscOutPerc = new GridBagConstraints();
		gbc_lblCurrDiscOutPerc.anchor = GridBagConstraints.EAST;
		gbc_lblCurrDiscOutPerc.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrDiscOutPerc.gridx = 2;
		gbc_lblCurrDiscOutPerc.gridy = 4;
		pnlGenInfo.add(lblCurrDiscOutPerc, gbc_lblCurrDiscOutPerc);
		
		txtCurrDiscOutPerc = new JTextArea();
		txtCurrDiscOutPerc.setEditable(false);
		GridBagConstraints gbc_txtCurrDiscOutPerc = new GridBagConstraints();
		gbc_txtCurrDiscOutPerc.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrDiscOutPerc.fill = GridBagConstraints.BOTH;
		gbc_txtCurrDiscOutPerc.gridx = 3;
		gbc_txtCurrDiscOutPerc.gridy = 4;
		pnlGenInfo.add(txtCurrDiscOutPerc, gbc_txtCurrDiscOutPerc);
		
		lblCurrDiscSumPerc = new JLabel("Discards sum (%):");
		GridBagConstraints gbc_lblCurrDiscSumPerc = new GridBagConstraints();
		gbc_lblCurrDiscSumPerc.anchor = GridBagConstraints.EAST;
		gbc_lblCurrDiscSumPerc.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrDiscSumPerc.gridx = 4;
		gbc_lblCurrDiscSumPerc.gridy = 4;
		pnlGenInfo.add(lblCurrDiscSumPerc, gbc_lblCurrDiscSumPerc);
		
		lblCurrUnIn = new JLabel("Unicast in (per second):");
		GridBagConstraints gbc_lblCurrUnIn = new GridBagConstraints();
		gbc_lblCurrUnIn.anchor = GridBagConstraints.EAST;
		gbc_lblCurrUnIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrUnIn.gridx = 0;
		gbc_lblCurrUnIn.gridy = 5;
		pnlGenInfo.add(lblCurrUnIn, gbc_lblCurrUnIn);
		
		txtCurrUnIn = new JTextArea();
		txtCurrUnIn.setEditable(false);
		GridBagConstraints gbc_txtCurrUnIn = new GridBagConstraints();
		gbc_txtCurrUnIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrUnIn.fill = GridBagConstraints.BOTH;
		gbc_txtCurrUnIn.gridx = 1;
		gbc_txtCurrUnIn.gridy = 5;
		pnlGenInfo.add(txtCurrUnIn, gbc_txtCurrUnIn);
		
		lblCurrUnOut = new JLabel("Unicast out (per second):");
		GridBagConstraints gbc_lblCurrUnOut = new GridBagConstraints();
		gbc_lblCurrUnOut.anchor = GridBagConstraints.EAST;
		gbc_lblCurrUnOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrUnOut.gridx = 2;
		gbc_lblCurrUnOut.gridy = 5;
		pnlGenInfo.add(lblCurrUnOut, gbc_lblCurrUnOut);
		
		txtCurrUnOut = new JTextArea();
		txtCurrUnOut.setEditable(false);
		GridBagConstraints gbc_txtCurrUnOut = new GridBagConstraints();
		gbc_txtCurrUnOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrUnOut.fill = GridBagConstraints.BOTH;
		gbc_txtCurrUnOut.gridx = 3;
		gbc_txtCurrUnOut.gridy = 5;
		pnlGenInfo.add(txtCurrUnOut, gbc_txtCurrUnOut);
		
		lblCurrUnSum = new JLabel("Unicast sum (per second):");
		GridBagConstraints gbc_lblCurrUnSum = new GridBagConstraints();
		gbc_lblCurrUnSum.anchor = GridBagConstraints.EAST;
		gbc_lblCurrUnSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrUnSum.gridx = 4;
		gbc_lblCurrUnSum.gridy = 5;
		pnlGenInfo.add(lblCurrUnSum, gbc_lblCurrUnSum);
		
		txtCurrUnSum = new JTextArea();
		txtCurrUnSum.setEditable(false);
		GridBagConstraints gbc_txtCurrUnSum = new GridBagConstraints();
		gbc_txtCurrUnSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrUnSum.fill = GridBagConstraints.BOTH;
		gbc_txtCurrUnSum.gridx = 5;
		gbc_txtCurrUnSum.gridy = 5;
		pnlGenInfo.add(txtCurrUnSum, gbc_txtCurrUnSum);
		
		lblCurrNUnIn = new JLabel("NUnicast in (per second):");
		GridBagConstraints gbc_lblCurrNUnIn = new GridBagConstraints();
		gbc_lblCurrNUnIn.anchor = GridBagConstraints.EAST;
		gbc_lblCurrNUnIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrNUnIn.gridx = 0;
		gbc_lblCurrNUnIn.gridy = 6;
		pnlGenInfo.add(lblCurrNUnIn, gbc_lblCurrNUnIn);
		
		txtCurrNUnIn = new JTextArea();
		txtCurrNUnIn.setEditable(false);
		GridBagConstraints gbc_txtCurrNUnIn = new GridBagConstraints();
		gbc_txtCurrNUnIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrNUnIn.fill = GridBagConstraints.BOTH;
		gbc_txtCurrNUnIn.gridx = 1;
		gbc_txtCurrNUnIn.gridy = 6;
		pnlGenInfo.add(txtCurrNUnIn, gbc_txtCurrNUnIn);
		
		lblCurrNUnOut = new JLabel("NUnicast out (per second):");
		GridBagConstraints gbc_lblCurrNUnOut = new GridBagConstraints();
		gbc_lblCurrNUnOut.anchor = GridBagConstraints.EAST;
		gbc_lblCurrNUnOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrNUnOut.gridx = 2;
		gbc_lblCurrNUnOut.gridy = 6;
		pnlGenInfo.add(lblCurrNUnOut, gbc_lblCurrNUnOut);
		
		txtCurrNUnOut = new JTextArea();
		txtCurrNUnOut.setEditable(false);
		GridBagConstraints gbc_txtCurrNUnOut = new GridBagConstraints();
		gbc_txtCurrNUnOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrNUnOut.fill = GridBagConstraints.BOTH;
		gbc_txtCurrNUnOut.gridx = 3;
		gbc_txtCurrNUnOut.gridy = 6;
		pnlGenInfo.add(txtCurrNUnOut, gbc_txtCurrNUnOut);
		
		lblCurrNUnSum = new JLabel("NUnicast sum (per second):");
		GridBagConstraints gbc_lblCurrNUnSum = new GridBagConstraints();
		gbc_lblCurrNUnSum.anchor = GridBagConstraints.EAST;
		gbc_lblCurrNUnSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrNUnSum.gridx = 4;
		gbc_lblCurrNUnSum.gridy = 6;
		pnlGenInfo.add(lblCurrNUnSum, gbc_lblCurrNUnSum);
		
		lblCurrPercIn = new JLabel("NUnicast / Unicast in (%):");
		GridBagConstraints gbc_lblCurrPercIn = new GridBagConstraints();
		gbc_lblCurrPercIn.anchor = GridBagConstraints.EAST;
		gbc_lblCurrPercIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrPercIn.gridx = 0;
		gbc_lblCurrPercIn.gridy = 7;
		pnlGenInfo.add(lblCurrPercIn, gbc_lblCurrPercIn);
		
		txtCurrPercIn = new JTextArea();
		txtCurrPercIn.setEditable(false);
		GridBagConstraints gbc_txtCurrPercIn = new GridBagConstraints();
		gbc_txtCurrPercIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrPercIn.fill = GridBagConstraints.BOTH;
		gbc_txtCurrPercIn.gridx = 1;
		gbc_txtCurrPercIn.gridy = 7;
		pnlGenInfo.add(txtCurrPercIn, gbc_txtCurrPercIn);
		
		lblCurrPercOut = new JLabel("NUnicast / Unicast out (%):");
		GridBagConstraints gbc_lblCurrPercOut = new GridBagConstraints();
		gbc_lblCurrPercOut.anchor = GridBagConstraints.EAST;
		gbc_lblCurrPercOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrPercOut.gridx = 2;
		gbc_lblCurrPercOut.gridy = 7;
		pnlGenInfo.add(lblCurrPercOut, gbc_lblCurrPercOut);
		
		txtCurrPercOut = new JTextArea();
		txtCurrPercOut.setEditable(false);
		GridBagConstraints gbc_txtCurrPercOut = new GridBagConstraints();
		gbc_txtCurrPercOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrPercOut.fill = GridBagConstraints.BOTH;
		gbc_txtCurrPercOut.gridx = 3;
		gbc_txtCurrPercOut.gridy = 7;
		pnlGenInfo.add(txtCurrPercOut, gbc_txtCurrPercOut);
		
		lblCurrPercSum = new JLabel("NUnicast / Unicast sum (%):");
		GridBagConstraints gbc_lblCurrPercSum = new GridBagConstraints();
		gbc_lblCurrPercSum.anchor = GridBagConstraints.EAST;
		gbc_lblCurrPercSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrPercSum.gridx = 4;
		gbc_lblCurrPercSum.gridy = 7;
		pnlGenInfo.add(lblCurrPercSum, gbc_lblCurrPercSum);
		
		lblCurrUtil = new JLabel("Utilization (%):");
		GridBagConstraints gbc_lblCurrUtil = new GridBagConstraints();
		gbc_lblCurrUtil.anchor = GridBagConstraints.EAST;
		gbc_lblCurrUtil.insets = new Insets(5, 5, 5, 5);
		gbc_lblCurrUtil.gridx = 0;
		gbc_lblCurrUtil.gridy = 8;
		pnlGenInfo.add(lblCurrUtil, gbc_lblCurrUtil);
		
		txtCurrUtil = new JTextArea();
		txtCurrUtil.setEditable(false);
		GridBagConstraints gbc_txtCurrUtil = new GridBagConstraints();
		gbc_txtCurrUtil.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtCurrUtil.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrUtil.gridx = 1;
		gbc_txtCurrUtil.gridy = 8;
		pnlGenInfo.add(txtCurrUtil, gbc_txtCurrUtil);
		
		txtCurrNUnSum = new JTextArea();
		txtCurrNUnSum.setEditable(false);
		GridBagConstraints gbc_txtCurrNUnSum = new GridBagConstraints();
		gbc_txtCurrNUnSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrNUnSum.fill = GridBagConstraints.BOTH;
		gbc_txtCurrNUnSum.gridx = 5;
		gbc_txtCurrNUnSum.gridy = 6;
		pnlGenInfo.add(txtCurrNUnSum, gbc_txtCurrNUnSum);
		
		txtCurrPercSum = new JTextArea();
		txtCurrPercSum.setEditable(false);
		GridBagConstraints gbc_txtCurrPercSum = new GridBagConstraints();
		gbc_txtCurrPercSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrPercSum.fill = GridBagConstraints.BOTH;
		gbc_txtCurrPercSum.gridx = 5;
		gbc_txtCurrPercSum.gridy = 7;
		pnlGenInfo.add(txtCurrPercSum, gbc_txtCurrPercSum);
		
		txtCurrDiscSumPerc = new JTextArea();
		txtCurrDiscSumPerc.setEditable(false);
		GridBagConstraints gbc_txtCurrDiscSumPerc = new GridBagConstraints();
		gbc_txtCurrDiscSumPerc.insets = new Insets(5, 5, 5, 5);
		gbc_txtCurrDiscSumPerc.fill = GridBagConstraints.BOTH;
		gbc_txtCurrDiscSumPerc.gridx = 5;
		gbc_txtCurrDiscSumPerc.gridy = 4;
		pnlGenInfo.add(txtCurrDiscSumPerc, gbc_txtCurrDiscSumPerc);
		
		txtAvgPercSum = new JTextArea();
		txtAvgPercSum.setEditable(false);
		GridBagConstraints gbc_txtAvgPercSum = new GridBagConstraints();
		gbc_txtAvgPercSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgPercSum.fill = GridBagConstraints.BOTH;
		gbc_txtAvgPercSum.gridx = 5;
		gbc_txtAvgPercSum.gridy = 17;
		pnlGenInfo.add(txtAvgPercSum, gbc_txtAvgPercSum);
		
		lblAvgPercSum = new JLabel("NUnicast / Unicast sum (%):");
		GridBagConstraints gbc_lblAvgPercSum = new GridBagConstraints();
		gbc_lblAvgPercSum.anchor = GridBagConstraints.EAST;
		gbc_lblAvgPercSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgPercSum.gridx = 4;
		gbc_lblAvgPercSum.gridy = 17;
		pnlGenInfo.add(lblAvgPercSum, gbc_lblAvgPercSum);
		
		txtAvgPercOut = new JTextArea();
		txtAvgPercOut.setEditable(false);
		GridBagConstraints gbc_txtAvgPercOut = new GridBagConstraints();
		gbc_txtAvgPercOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgPercOut.fill = GridBagConstraints.BOTH;
		gbc_txtAvgPercOut.gridx = 3;
		gbc_txtAvgPercOut.gridy = 17;
		pnlGenInfo.add(txtAvgPercOut, gbc_txtAvgPercOut);
		
		lblAvgPercOut = new JLabel("NUnicast / Unicast out (%):");
		GridBagConstraints gbc_lblAvgPercOut = new GridBagConstraints();
		gbc_lblAvgPercOut.anchor = GridBagConstraints.EAST;
		gbc_lblAvgPercOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgPercOut.gridx = 2;
		gbc_lblAvgPercOut.gridy = 17;
		pnlGenInfo.add(lblAvgPercOut, gbc_lblAvgPercOut);
		
		txtAvgPercIn = new JTextArea();
		txtAvgPercIn.setEditable(false);
		GridBagConstraints gbc_txtAvgPercIn = new GridBagConstraints();
		gbc_txtAvgPercIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgPercIn.fill = GridBagConstraints.BOTH;
		gbc_txtAvgPercIn.gridx = 1;
		gbc_txtAvgPercIn.gridy = 17;
		pnlGenInfo.add(txtAvgPercIn, gbc_txtAvgPercIn);
		
		lblAvgPercIn = new JLabel("NUnicast / Unicast in (%):");
		GridBagConstraints gbc_lblAvgPercIn = new GridBagConstraints();
		gbc_lblAvgPercIn.anchor = GridBagConstraints.EAST;
		gbc_lblAvgPercIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgPercIn.gridx = 0;
		gbc_lblAvgPercIn.gridy = 17;
		pnlGenInfo.add(lblAvgPercIn, gbc_lblAvgPercIn);
		
		txtAvgNUnSum = new JTextArea();
		txtAvgNUnSum.setEditable(false);
		GridBagConstraints gbc_txtAvgNUnSum = new GridBagConstraints();
		gbc_txtAvgNUnSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgNUnSum.fill = GridBagConstraints.BOTH;
		gbc_txtAvgNUnSum.gridx = 5;
		gbc_txtAvgNUnSum.gridy = 16;
		pnlGenInfo.add(txtAvgNUnSum, gbc_txtAvgNUnSum);
		
		lblAvgUNSum = new JLabel("NUnicast sum (per second):");
		GridBagConstraints gbc_lblAvgUNSum = new GridBagConstraints();
		gbc_lblAvgUNSum.anchor = GridBagConstraints.EAST;
		gbc_lblAvgUNSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgUNSum.gridx = 4;
		gbc_lblAvgUNSum.gridy = 16;
		pnlGenInfo.add(lblAvgUNSum, gbc_lblAvgUNSum);
		
		txtAvgNUnOut = new JTextArea();
		txtAvgNUnOut.setEditable(false);
		GridBagConstraints gbc_txtAvgNUnOut = new GridBagConstraints();
		gbc_txtAvgNUnOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgNUnOut.fill = GridBagConstraints.BOTH;
		gbc_txtAvgNUnOut.gridx = 3;
		gbc_txtAvgNUnOut.gridy = 16;
		pnlGenInfo.add(txtAvgNUnOut, gbc_txtAvgNUnOut);
		
		lblAvgNUnOut = new JLabel("NUnicast out (per second):");
		GridBagConstraints gbc_lblAvgNUnOut = new GridBagConstraints();
		gbc_lblAvgNUnOut.anchor = GridBagConstraints.EAST;
		gbc_lblAvgNUnOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgNUnOut.gridx = 2;
		gbc_lblAvgNUnOut.gridy = 16;
		pnlGenInfo.add(lblAvgNUnOut, gbc_lblAvgNUnOut);
		
		txtAvgNUnIn = new JTextArea();
		txtAvgNUnIn.setEditable(false);
		GridBagConstraints gbc_txtAvgNUnIn = new GridBagConstraints();
		gbc_txtAvgNUnIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgNUnIn.fill = GridBagConstraints.BOTH;
		gbc_txtAvgNUnIn.gridx = 1;
		gbc_txtAvgNUnIn.gridy = 16;
		pnlGenInfo.add(txtAvgNUnIn, gbc_txtAvgNUnIn);
		
		lblAvgNUnIn = new JLabel("NUnicast in (per second):");
		GridBagConstraints gbc_lblAvgNUnIn = new GridBagConstraints();
		gbc_lblAvgNUnIn.anchor = GridBagConstraints.EAST;
		gbc_lblAvgNUnIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgNUnIn.gridx = 0;
		gbc_lblAvgNUnIn.gridy = 16;
		pnlGenInfo.add(lblAvgNUnIn, gbc_lblAvgNUnIn);
		
		txtAvgUnSum = new JTextArea();
		txtAvgUnSum.setEditable(false);
		GridBagConstraints gbc_txtAvgUnSum = new GridBagConstraints();
		gbc_txtAvgUnSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgUnSum.fill = GridBagConstraints.BOTH;
		gbc_txtAvgUnSum.gridx = 5;
		gbc_txtAvgUnSum.gridy = 15;
		pnlGenInfo.add(txtAvgUnSum, gbc_txtAvgUnSum);
		
		lblAvgUnSum = new JLabel("Unicast sum (per second):");
		GridBagConstraints gbc_lblAvgUnSum = new GridBagConstraints();
		gbc_lblAvgUnSum.anchor = GridBagConstraints.EAST;
		gbc_lblAvgUnSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgUnSum.gridx = 4;
		gbc_lblAvgUnSum.gridy = 15;
		pnlGenInfo.add(lblAvgUnSum, gbc_lblAvgUnSum);
		
		txtAvgUnOut = new JTextArea();
		txtAvgUnOut.setEditable(false);
		GridBagConstraints gbc_txtAvgUnOut = new GridBagConstraints();
		gbc_txtAvgUnOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgUnOut.fill = GridBagConstraints.BOTH;
		gbc_txtAvgUnOut.gridx = 3;
		gbc_txtAvgUnOut.gridy = 15;
		pnlGenInfo.add(txtAvgUnOut, gbc_txtAvgUnOut);
		
		lblAvgUnOut = new JLabel("Unicast out (per second):");
		GridBagConstraints gbc_lblAvgUnOut = new GridBagConstraints();
		gbc_lblAvgUnOut.anchor = GridBagConstraints.EAST;
		gbc_lblAvgUnOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgUnOut.gridx = 2;
		gbc_lblAvgUnOut.gridy = 15;
		pnlGenInfo.add(lblAvgUnOut, gbc_lblAvgUnOut);
		
		txtAvgUnIn = new JTextArea();
		txtAvgUnIn.setEditable(false);
		GridBagConstraints gbc_txtAvgUnIn = new GridBagConstraints();
		gbc_txtAvgUnIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgUnIn.fill = GridBagConstraints.BOTH;
		gbc_txtAvgUnIn.gridx = 1;
		gbc_txtAvgUnIn.gridy = 15;
		pnlGenInfo.add(txtAvgUnIn, gbc_txtAvgUnIn);
		
		lblAvgUnIn = new JLabel("Unicast in (per second):");
		GridBagConstraints gbc_lblAvgUnIn = new GridBagConstraints();
		gbc_lblAvgUnIn.anchor = GridBagConstraints.EAST;
		gbc_lblAvgUnIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgUnIn.gridx = 0;
		gbc_lblAvgUnIn.gridy = 15;
		pnlGenInfo.add(lblAvgUnIn, gbc_lblAvgUnIn);
		
		txtAvgDiscSumPerc = new JTextArea();
		txtAvgDiscSumPerc.setText("N/A");
		txtAvgDiscSumPerc.setEditable(false);
		GridBagConstraints gbc_txtAvgDiscSumPerc = new GridBagConstraints();
		gbc_txtAvgDiscSumPerc.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgDiscSumPerc.fill = GridBagConstraints.BOTH;
		gbc_txtAvgDiscSumPerc.gridx = 5;
		gbc_txtAvgDiscSumPerc.gridy = 14;
		pnlGenInfo.add(txtAvgDiscSumPerc, gbc_txtAvgDiscSumPerc);
		
		lblAvgDiscSumPerc = new JLabel("Discards sum (%):");
		GridBagConstraints gbc_lblAvgDiscSumPerc = new GridBagConstraints();
		gbc_lblAvgDiscSumPerc.anchor = GridBagConstraints.EAST;
		gbc_lblAvgDiscSumPerc.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgDiscSumPerc.gridx = 4;
		gbc_lblAvgDiscSumPerc.gridy = 14;
		pnlGenInfo.add(lblAvgDiscSumPerc, gbc_lblAvgDiscSumPerc);
		
		txtAvgDiscOutPerc = new JTextArea();
		txtAvgDiscOutPerc.setText("N/A");
		txtAvgDiscOutPerc.setEditable(false);
		GridBagConstraints gbc_txtAvgDiscOutPerc = new GridBagConstraints();
		gbc_txtAvgDiscOutPerc.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgDiscOutPerc.fill = GridBagConstraints.BOTH;
		gbc_txtAvgDiscOutPerc.gridx = 3;
		gbc_txtAvgDiscOutPerc.gridy = 14;
		pnlGenInfo.add(txtAvgDiscOutPerc, gbc_txtAvgDiscOutPerc);
		
		lblAvgDiscOutPerc = new JLabel("Discards out (%):");
		GridBagConstraints gbc_lblAvgDiscOutPerc = new GridBagConstraints();
		gbc_lblAvgDiscOutPerc.anchor = GridBagConstraints.EAST;
		gbc_lblAvgDiscOutPerc.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgDiscOutPerc.gridx = 2;
		gbc_lblAvgDiscOutPerc.gridy = 14;
		pnlGenInfo.add(lblAvgDiscOutPerc, gbc_lblAvgDiscOutPerc);
		
		txtAvgDiscPercIn = new JTextArea();
		txtAvgDiscPercIn.setText("N/A");
		txtAvgDiscPercIn.setEditable(false);
		GridBagConstraints gbc_txtAvgDiscPercIn = new GridBagConstraints();
		gbc_txtAvgDiscPercIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgDiscPercIn.fill = GridBagConstraints.BOTH;
		gbc_txtAvgDiscPercIn.gridx = 1;
		gbc_txtAvgDiscPercIn.gridy = 14;
		pnlGenInfo.add(txtAvgDiscPercIn, gbc_txtAvgDiscPercIn);
		
		lblAvgDiscPercIn = new JLabel("Discards in (%):");
		GridBagConstraints gbc_lblAvgDiscPercIn = new GridBagConstraints();
		gbc_lblAvgDiscPercIn.anchor = GridBagConstraints.EAST;
		gbc_lblAvgDiscPercIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgDiscPercIn.gridx = 0;
		gbc_lblAvgDiscPercIn.gridy = 14;
		pnlGenInfo.add(lblAvgDiscPercIn, gbc_lblAvgDiscPercIn);
		
		txtAvgDiscSum = new JTextArea();
		txtAvgDiscSum.setText("N/A");
		txtAvgDiscSum.setEditable(false);
		GridBagConstraints gbc_txtAvgDiscSum = new GridBagConstraints();
		gbc_txtAvgDiscSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgDiscSum.fill = GridBagConstraints.BOTH;
		gbc_txtAvgDiscSum.gridx = 5;
		gbc_txtAvgDiscSum.gridy = 13;
		pnlGenInfo.add(txtAvgDiscSum, gbc_txtAvgDiscSum);
		
		lblAvgDiscSum = new JLabel("Discards sum (per second):");
		GridBagConstraints gbc_lblAvgDiscSum = new GridBagConstraints();
		gbc_lblAvgDiscSum.anchor = GridBagConstraints.EAST;
		gbc_lblAvgDiscSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgDiscSum.gridx = 4;
		gbc_lblAvgDiscSum.gridy = 13;
		pnlGenInfo.add(lblAvgDiscSum, gbc_lblAvgDiscSum);
		
		txtAvgDiscOut = new JTextArea();
		txtAvgDiscOut.setText("N/A");
		txtAvgDiscOut.setEditable(false);
		GridBagConstraints gbc_txtAvgDiscOut = new GridBagConstraints();
		gbc_txtAvgDiscOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgDiscOut.fill = GridBagConstraints.BOTH;
		gbc_txtAvgDiscOut.gridx = 3;
		gbc_txtAvgDiscOut.gridy = 13;
		pnlGenInfo.add(txtAvgDiscOut, gbc_txtAvgDiscOut);
		
		lblAvgDiscOut = new JLabel("Discards out (per second):");
		GridBagConstraints gbc_lblAvgDiscOut = new GridBagConstraints();
		gbc_lblAvgDiscOut.anchor = GridBagConstraints.EAST;
		gbc_lblAvgDiscOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgDiscOut.gridx = 2;
		gbc_lblAvgDiscOut.gridy = 13;
		pnlGenInfo.add(lblAvgDiscOut, gbc_lblAvgDiscOut);
		
		txtAvgDiscIn = new JTextArea();
		txtAvgDiscIn.setText("N/A");
		txtAvgDiscIn.setEditable(false);
		GridBagConstraints gbc_txtAvgDiscIn = new GridBagConstraints();
		gbc_txtAvgDiscIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgDiscIn.fill = GridBagConstraints.BOTH;
		gbc_txtAvgDiscIn.gridx = 1;
		gbc_txtAvgDiscIn.gridy = 13;
		pnlGenInfo.add(txtAvgDiscIn, gbc_txtAvgDiscIn);
		
		lblAvgDiscIn = new JLabel("Discards in (per second):");
		GridBagConstraints gbc_lblAvgDiscIn = new GridBagConstraints();
		gbc_lblAvgDiscIn.anchor = GridBagConstraints.EAST;
		gbc_lblAvgDiscIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgDiscIn.gridx = 0;
		gbc_lblAvgDiscIn.gridy = 13;
		pnlGenInfo.add(lblAvgDiscIn, gbc_lblAvgDiscIn);
		
		lblAvgStats = new JLabel("Average interface stats");
		lblAvgStats.setFont(new Font("Tahoma", Font.BOLD, 13));
		GridBagConstraints gbc_lblAvgStats = new GridBagConstraints();
		gbc_lblAvgStats.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgStats.gridx = 0;
		gbc_lblAvgStats.gridy = 10;
		pnlGenInfo.add(lblAvgStats, gbc_lblAvgStats);
		
		lblAvgTIn = new JLabel("Throughput in (per second):");
		GridBagConstraints gbc_lblAvgTIn = new GridBagConstraints();
		gbc_lblAvgTIn.anchor = GridBagConstraints.EAST;
		gbc_lblAvgTIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgTIn.gridx = 0;
		gbc_lblAvgTIn.gridy = 11;
		pnlGenInfo.add(lblAvgTIn, gbc_lblAvgTIn);
		
		txtAvgTIn = new JTextArea();
		txtAvgTIn.setEditable(false);
		GridBagConstraints gbc_txtAvgTIn = new GridBagConstraints();
		gbc_txtAvgTIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgTIn.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtAvgTIn.gridx = 1;
		gbc_txtAvgTIn.gridy = 11;
		pnlGenInfo.add(txtAvgTIn, gbc_txtAvgTIn);
		
		lblAvgTOut = new JLabel("Throughput out (per second):");
		GridBagConstraints gbc_lblAvgTOut = new GridBagConstraints();
		gbc_lblAvgTOut.anchor = GridBagConstraints.EAST;
		gbc_lblAvgTOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgTOut.gridx = 2;
		gbc_lblAvgTOut.gridy = 11;
		pnlGenInfo.add(lblAvgTOut, gbc_lblAvgTOut);
		
		txtAvgTOut = new JTextArea();
		txtAvgTOut.setEditable(false);
		GridBagConstraints gbc_txtAvgTOut = new GridBagConstraints();
		gbc_txtAvgTOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgTOut.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtAvgTOut.gridx = 3;
		gbc_txtAvgTOut.gridy = 11;
		pnlGenInfo.add(txtAvgTOut, gbc_txtAvgTOut);
		
		lblAvgThroughSum = new JLabel("Throughput sum (per second):");
		GridBagConstraints gbc_lblAvgThroughSum = new GridBagConstraints();
		gbc_lblAvgThroughSum.anchor = GridBagConstraints.EAST;
		gbc_lblAvgThroughSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgThroughSum.gridx = 4;
		gbc_lblAvgThroughSum.gridy = 11;
		pnlGenInfo.add(lblAvgThroughSum, gbc_lblAvgThroughSum);
		
		lblAvgPIn = new JLabel("Packets in (per second):");
		GridBagConstraints gbc_lblAvgPIn = new GridBagConstraints();
		gbc_lblAvgPIn.anchor = GridBagConstraints.EAST;
		gbc_lblAvgPIn.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgPIn.gridx = 0;
		gbc_lblAvgPIn.gridy = 12;
		pnlGenInfo.add(lblAvgPIn, gbc_lblAvgPIn);
		
		txtAvgPIn = new JTextArea();
		txtAvgPIn.setEditable(false);
		GridBagConstraints gbc_txtAvgPIn = new GridBagConstraints();
		gbc_txtAvgPIn.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgPIn.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtAvgPIn.gridx = 1;
		gbc_txtAvgPIn.gridy = 12;
		pnlGenInfo.add(txtAvgPIn, gbc_txtAvgPIn);
		
		lblAvgPOut = new JLabel("Packets out (per second):");
		GridBagConstraints gbc_lblAvgPOut = new GridBagConstraints();
		gbc_lblAvgPOut.anchor = GridBagConstraints.EAST;
		gbc_lblAvgPOut.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgPOut.gridx = 2;
		gbc_lblAvgPOut.gridy = 12;
		pnlGenInfo.add(lblAvgPOut, gbc_lblAvgPOut);
		
		txtAvgPOut = new JTextArea();
		txtAvgPOut.setEditable(false);
		GridBagConstraints gbc_txtAvgPOut = new GridBagConstraints();
		gbc_txtAvgPOut.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgPOut.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtAvgPOut.gridx = 3;
		gbc_txtAvgPOut.gridy = 12;
		pnlGenInfo.add(txtAvgPOut, gbc_txtAvgPOut);
		
		lblAvgPktsSum = new JLabel("Packets sum (per second):");
		GridBagConstraints gbc_lblAvgPktsSum = new GridBagConstraints();
		gbc_lblAvgPktsSum.anchor = GridBagConstraints.EAST;
		gbc_lblAvgPktsSum.insets = new Insets(5, 5, 5, 5);
		gbc_lblAvgPktsSum.gridx = 4;
		gbc_lblAvgPktsSum.gridy = 12;
		pnlGenInfo.add(lblAvgPktsSum, gbc_lblAvgPktsSum);
		
		lblAvgUtil = new JLabel("Utilization (%):");
		GridBagConstraints gbc_lblAvgUtil = new GridBagConstraints();
		gbc_lblAvgUtil.anchor = GridBagConstraints.EAST;
		gbc_lblAvgUtil.insets = new Insets(5, 5, 0, 5);
		gbc_lblAvgUtil.gridx = 0;
		gbc_lblAvgUtil.gridy = 18;
		pnlGenInfo.add(lblAvgUtil, gbc_lblAvgUtil);
		
		txtAvgUtil = new JTextArea();
		txtAvgUtil.setEditable(false);
		GridBagConstraints gbc_txtAvgUtil = new GridBagConstraints();
		gbc_txtAvgUtil.insets = new Insets(5, 5, 0, 5);
		gbc_txtAvgUtil.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtAvgUtil.gridx = 1;
		gbc_txtAvgUtil.gridy = 18;
		pnlGenInfo.add(txtAvgUtil, gbc_txtAvgUtil);
		
		txtAvgThroughSum = new JTextArea();
		txtAvgThroughSum.setEditable(false);
		GridBagConstraints gbc_txtAvgThroughSum = new GridBagConstraints();
		gbc_txtAvgThroughSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgThroughSum.fill = GridBagConstraints.BOTH;
		gbc_txtAvgThroughSum.gridx = 5;
		gbc_txtAvgThroughSum.gridy = 11;
		pnlGenInfo.add(txtAvgThroughSum, gbc_txtAvgThroughSum);
		
		txtAvgPktsSum = new JTextArea();
		txtAvgPktsSum.setEditable(false);
		GridBagConstraints gbc_txtAvgPktsSum = new GridBagConstraints();
		gbc_txtAvgPktsSum.insets = new Insets(5, 5, 5, 5);
		gbc_txtAvgPktsSum.fill = GridBagConstraints.BOTH;
		gbc_txtAvgPktsSum.gridx = 5;
		gbc_txtAvgPktsSum.gridy = 12;
		pnlGenInfo.add(txtAvgPktsSum, gbc_txtAvgPktsSum);
		
		lblDetTitle.setText("Details for Interface Index: " + ifId);
		throughputIn = new TimeSeries("In", Second.class);
		packetsIn = new TimeSeries("In", Second.class);
		throughputOut = new TimeSeries("Out", Second.class);
		packetsOut = new TimeSeries("Out", Second.class);
		
		createCharts(throughputChart, throughputIn, throughputOut, "Throughput Chart", "KBs");
		createCharts(packetsChart, packetsIn, packetsOut, "Packets Chart", "Packets");
		
		infoDet.addSnmpValueListener(this);
		infoDet.start();
	}
	
	/*
	private void startTimer() {
		timer = new Timer();
		timer.schedule(new TimerTask() {

			@Override
			public void run() {
				if ((!isFinished) && (client != null) && (infoDet != null)) {
					if ((infoDet.eof()) || (infoDet.bof())) {
						if (infoDet.eof()) {
							infoDet.gotoStart();
						}
						
						client.get(new OID[] {
								new OID(infoDet.getNextOID() + "." + ifId),
							}, thispnl, 
							new Object[] {
								infoDet
							}, PDU.GET, null);
					}
					else {
						System.out.println("Jumped a period");
					}
				}
			}
			
		}, 1000, 1000);
	}
	*/
	
	private void updateUiValues() {
		DecimalFormat df = new DecimalFormat("#.#");
		txtCurrTIn.setText(getFormattedThroughput(infoDet.getCurrIfInOctets()));
		txtCurrTOut.setText(getFormattedThroughput(infoDet.getCurrIfOutOctets()));
		txtCurrThroughSum.setText(getFormattedThroughput(infoDet.getCurrIfOutOctets() + infoDet.getCurrIfOutOctets()));
		
		long currInPkts = infoDet.getCurrIfInNUcastPkts() + infoDet.getCurrIfInUcastPkts() + infoDet.getCurrIfInDiscards();
		long currOutPkts = infoDet.getCurrIfOutNUcastPkts() + infoDet.getCurrIfOutUcastPkts() + infoDet.getCurrIfOutDiscards();
		txtCurrPIn.setText(currInPkts + "");
		txtCurrPOut.setText(currOutPkts + "");
		
		txtCurrPktsSum.setText((currOutPkts + currInPkts) + "");
		
		txtCurrUnIn.setText(infoDet.getCurrIfInUcastPkts() + "");
		txtCurrUnOut.setText(infoDet.getCurrIfOutUcastPkts() + "");
		txtCurrUnSum.setText((infoDet.getCurrIfInUcastPkts() + infoDet.getCurrIfOutUcastPkts()) + "");
		
		txtCurrNUnIn.setText(infoDet.getCurrIfInNUcastPkts() + "");
		txtCurrNUnOut.setText(infoDet.getCurrIfOutNUcastPkts() + "");
		txtCurrNUnSum.setText((infoDet.getCurrIfInNUcastPkts() + infoDet.getCurrIfOutNUcastPkts()) + "");
		
		double currInUnPkts = infoDet.getCurrIfInUcastPkts();
		double currInNUnPkts = infoDet.getCurrIfInNUcastPkts();
		double currOutUnPkts = infoDet.getCurrIfOutUcastPkts();
		double currOutNUnPkts = infoDet.getCurrIfOutNUcastPkts();
		double currSumUnPkts = currInUnPkts + currOutUnPkts;
		double currSumNUnPkts = currInNUnPkts + currOutNUnPkts;
		
		double currInPerc = 0;
		if (currInUnPkts != 0.0) {
			currInPerc = 100 * currInNUnPkts / currInUnPkts;
		}
		
		double currOutPerc = 0;
		if (currOutUnPkts != 0.0) {
			currOutPerc = 100 * currOutNUnPkts / currOutUnPkts;
		}
		
		double currSumPerc = 0;
		if (currSumUnPkts != 0.0) {
			currSumPerc = 100 * currSumNUnPkts / currSumUnPkts;
		}
		
		txtCurrPercIn.setText(df.format(currInPerc));
		txtCurrPercOut.setText(df.format(currOutPerc));
		txtCurrPercSum.setText(df.format(currSumPerc));
		
		double discPercIn = 0.0;
		if (currInPkts > 0) {
			discPercIn = 100.0 * ((double)infoDet.getCurrIfInDiscards()) / ((double)currInPkts);
		}
		double discPercOut = 0.0;
		if (currOutPkts > 0) {
			discPercOut = 100.0 * ((double)infoDet.getCurrIfOutDiscards()) / ((double)currOutPkts);
		}
		double discPercSum = 0.0;
		if ((currOutPkts > 0) || (currInPkts > 0)) {
			discPercSum = 100.0 * ((double)(infoDet.getCurrIfInDiscards() + infoDet.getCurrIfOutDiscards())) / ((double)(currOutPkts + currInPkts));
		}
		
		txtCurrDiscInPerc.setText(df.format(discPercIn));
		txtCurrDiscOutPerc.setText(df.format(discPercOut));
		txtCurrDiscSumPerc.setText(df.format(discPercSum));
		
		txtCurrDiscIn.setText(infoDet.getCurrIfInDiscards() + "");
		txtCurrDiscOut.setText(infoDet.getCurrIfOutDiscards() + "");
		txtCurrDiscSum.setText((infoDet.getCurrIfOutDiscards() + infoDet.getCurrIfInDiscards()) + "");
		
		long sumCurrThrough = infoDet.getCurrIfInOctets() + infoDet.getCurrIfOutOctets();
		double currUtil = 0.0;
		if (infoDet.getIfSpeed() != 0) {
			currUtil = (((double)sumCurrThrough) / ((double)infoDet.getIfSpeed())) * 100.0;
		}
		txtCurrUtil.setText(df.format(currUtil));
		
		double val = getValueInKB(infoDet.getCurrIfInOctets());
		Calendar cal = Calendar.getInstance();
		throughputIn.add(
				new Second(cal.get(Calendar.SECOND),
						   cal.get(Calendar.MINUTE),
						   cal.get(Calendar.HOUR_OF_DAY),
						   cal.get(Calendar.DAY_OF_WEEK),
						   cal.get(Calendar.MONTH),
						   cal.get(Calendar.YEAR)), val);
		
		val = infoDet.getCurrIfOutOctets();
		throughputOut.add(
				new Second(cal.get(Calendar.SECOND),
						   cal.get(Calendar.MINUTE),
						   cal.get(Calendar.HOUR_OF_DAY),
						   cal.get(Calendar.DAY_OF_WEEK),
						   cal.get(Calendar.MONTH),
						   cal.get(Calendar.YEAR)), val);
		
		val = currInPkts;
		packetsIn.add(
				new Second(cal.get(Calendar.SECOND),
						   cal.get(Calendar.MINUTE),
						   cal.get(Calendar.HOUR_OF_DAY),
						   cal.get(Calendar.DAY_OF_WEEK),
						   cal.get(Calendar.MONTH),
						   cal.get(Calendar.YEAR)), val);
		
		val = currOutPkts;
		packetsOut.add(
				new Second(cal.get(Calendar.SECOND),
						   cal.get(Calendar.MINUTE),
						   cal.get(Calendar.HOUR_OF_DAY),
						   cal.get(Calendar.DAY_OF_WEEK),
						   cal.get(Calendar.MONTH),
						   cal.get(Calendar.YEAR)), val);
		
		txtAvgTIn.setText(getFormattedThroughput(infoDet.getAvgIfInOctets()));
		txtAvgTOut.setText(getFormattedThroughput(infoDet.getAvgIfOutOctets()));
		txtAvgThroughSum.setText(getFormattedThroughput(infoDet.getAvgIfInOctets() + infoDet.getAvgIfOutOctets()));
		
		double avgInPkts = infoDet.getAvgIfInNUcastPkts() + infoDet.getAvgIfInUcastPkts();
		double avgOutPkts = infoDet.getAvgIfOutNUcastPkts() + infoDet.getAvgIfOutUcastPkts();
		txtAvgPIn.setText(df.format(avgInPkts));
		txtAvgPOut.setText(df.format(avgOutPkts));
		
		txtAvgPktsSum.setText(df.format(avgInPkts + avgOutPkts));
		
		txtAvgUnIn.setText(df.format(infoDet.getAvgIfInUcastPkts()));
		txtAvgUnOut.setText(df.format(infoDet.getAvgIfOutUcastPkts()));
		txtAvgUnSum.setText(df.format(infoDet.getAvgIfInUcastPkts() + infoDet.getAvgIfOutUcastPkts()));
		
		txtAvgNUnIn.setText(df.format(infoDet.getAvgIfInNUcastPkts()));
		txtAvgNUnOut.setText(df.format(infoDet.getAvgIfOutNUcastPkts()));
		txtAvgNUnSum.setText(df.format(infoDet.getAvgIfInNUcastPkts() + infoDet.getAvgIfOutNUcastPkts()));
		
		double avgInUnPkts = infoDet.getAvgIfInUcastPkts();
		double avgInNUnPkts = infoDet.getAvgIfInNUcastPkts();
		double avgOutUnPkts = infoDet.getAvgIfOutUcastPkts();
		double avgOutNUnPkts = infoDet.getAvgIfOutNUcastPkts();
		double avgSumUnPkts = avgInUnPkts + avgOutUnPkts;
		double avgSumNUnPkts = avgInNUnPkts + avgOutNUnPkts;
		
		double avgInPerc = 0;
		if (avgInUnPkts != 0.0) {
			avgInPerc = 100 * avgInNUnPkts / avgInUnPkts;
		}
		
		double avgOutPerc = 0;
		if (avgOutUnPkts != 0.0) {
			avgOutPerc = 100 * avgOutNUnPkts / avgOutUnPkts;
		}
		
		double avgSumPerc = 0;
		if (avgSumUnPkts != 0.0) {
			avgSumPerc = 100 * avgSumNUnPkts / avgSumUnPkts;
		}
		
		txtAvgPercIn.setText(df.format(avgInPerc));
		txtAvgPercOut.setText(df.format(avgOutPerc));
		txtAvgPercSum.setText(df.format(avgSumPerc));
		
		/*txtAvgDiscIn.setText(df.format(infoDet.getAvgIfInDiscards()));
		txtAvgDiscOut.setText(df.format(infoDet.getAvgIfOutDiscards()));
		txtAvgDiscSum.setText(df.format(infoDet.getAvgIfOutDiscards() + infoDet.getAvgIfInDiscards()));*/
		
		double sumAvgThrough = infoDet.getAvgIfInOctets() + infoDet.getAvgIfOutOctets();
		double avgUtil = 0.0;
		if (infoDet.getIfSpeed() != 0) {
			avgUtil = (((double)sumAvgThrough) / ((double)infoDet.getIfSpeed())) * 100.0;
		}
		txtAvgUtil.setText(df.format(avgUtil));
	}
	
	private final static long KB = 1024;
	private final static long MB = 1024 * KB;
	private final static long GB = 1024 * MB;
	
	private double getValueInKB(long throughput) {
		return ((double)throughput) / ((double)KB);
	}
	
	private String getFormattedThroughput(long throughput) {
		double res = 0;
		DecimalFormat df = new DecimalFormat("#.#");
		if (throughput < KB) {
			return throughput + " B";
		}
		else if (throughput < MB) {
			res = ((double)throughput) / ((double)KB); 
			return df.format(res) + " KB";
		}
		else if (throughput < GB) {
			res = ((double)throughput) / ((double)MB); 
			return df.format(res) + " MB";
		}
		else {
			res = ((double)throughput) / ((double)GB); 
			return df.format(res) + " GB";
		}
	}
	
	private final static double dKB = 1024;
	private final static double dMB = 1024 * dKB;
	private final static double dGB = 1024 * dMB;
	private JPanel pnlCharts;
	private JLabel lblCurrThroughSum;
	private JTextArea txtCurrThroughSum;
	private JLabel lblCurrPktsSum;
	private JTextArea txtCurrPktsSum;
	private JLabel lblAvgThroughSum;
	private JLabel lblAvgPktsSum;
	private JTextArea txtAvgThroughSum;
	private JTextArea txtAvgPktsSum;
	private JLabel lblCurrDiscIn;
	private JTextArea txtCurrDiscIn;
	private JLabel lblCurrDiscOut;
	private JTextArea txtCurrDiscOut;
	private JLabel lblCurrDiscSum;
	private JTextArea txtCurrDiscSum;
	private JLabel lblCurrUnIn;
	private JTextArea txtCurrUnIn;
	private JLabel lblCurrUnOut;
	private JTextArea txtCurrUnOut;
	private JLabel lblCurrUnSum;
	private JTextArea txtCurrUnSum;
	private JLabel lblCurrNUnIn;
	private JTextArea txtCurrNUnIn;
	private JLabel lblCurrNUnOut;
	private JTextArea txtCurrNUnOut;
	private JLabel lblCurrNUnSum;
	private JTextArea txtCurrNUnSum;
	private JLabel lblCurrPercIn;
	private JTextArea txtCurrPercIn;
	private JLabel lblCurrPercOut;
	private JTextArea txtCurrPercOut;
	private JLabel lblCurrPercSum;
	private JTextArea txtCurrPercSum;
	private JLabel lblCurrDiscInPerc;
	private JTextArea txtCurrDiscInPerc;
	private JLabel lblCurrDiscOutPerc;
	private JTextArea txtCurrDiscOutPerc;
	private JLabel lblCurrDiscSumPerc;
	private JTextArea txtCurrDiscSumPerc;
	private JLabel lblAvgDiscIn;
	private JTextArea txtAvgDiscIn;
	private JLabel lblAvgDiscOut;
	private JTextArea txtAvgDiscOut;
	private JLabel lblAvgDiscSum;
	private JTextArea txtAvgDiscSum;
	private JLabel lblAvgDiscPercIn;
	private JTextArea txtAvgDiscPercIn;
	private JLabel lblAvgDiscOutPerc;
	private JTextArea txtAvgDiscOutPerc;
	private JLabel lblAvgDiscSumPerc;
	private JTextArea txtAvgDiscSumPerc;
	private JLabel lblAvgUnIn;
	private JTextArea txtAvgUnIn;
	private JLabel lblAvgUnOut;
	private JTextArea txtAvgUnOut;
	private JLabel lblAvgUnSum;
	private JTextArea txtAvgUnSum;
	private JLabel lblAvgNUnIn;
	private JTextArea txtAvgNUnIn;
	private JLabel lblAvgNUnOut;
	private JTextArea txtAvgNUnOut;
	private JLabel lblAvgUNSum;
	private JTextArea txtAvgNUnSum;
	private JLabel lblAvgPercIn;
	private JTextArea txtAvgPercIn;
	private JLabel lblAvgPercOut;
	private JTextArea txtAvgPercOut;
	private JLabel lblAvgPercSum;
	private JTextArea txtAvgPercSum;
	
	private String getFormattedThroughput(double throughput) {
		double res = 0;
		DecimalFormat df = new DecimalFormat("#.#");
		if (throughput < dKB) {
			return df.format(throughput) + " B";
		}
		else if (throughput < dMB) {
			res = ((double)throughput) / ((double)dKB); 
			return df.format(res) + " KB";
		}
		else if (throughput < dGB) {
			res = ((double)throughput) / ((double)dMB); 
			return df.format(res) + " MB";
		}
		else {
			res = ((double)throughput) / ((double)dGB); 
			return df.format(res) + " GB";
		}
	}
	
	
	public void stop() {
		infoDet.stop();
		infoDet = null;
	}

	/*
	@Override
	public void onResponse(final ResponseEvent response) {
		if (isFinished) {
			return;
		}
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				if (isFinished) {
					return;
				}
				
				if (response == null) {
					System.out.println("Error while getting snmp response object");
				}
				else if (response.getError() != null) {
					System.out.println(response.getError().getMessage());
				}
				else if ((response.getUserObject() != null) && (response.getUserObject() instanceof Object[])) {
					Object[] userObjects = (Object[])response.getUserObject();
					for (int i = 0; i < userObjects.length; i++) {
						if (userObjects[i] != null) {
							if (userObjects[i] instanceof InterfaceInfoDetails) {
								InterfaceInfoDetails info = (InterfaceInfoDetails)userObjects[i];
								info.setCurrentValue(response.getResponse(), response.getRequest());
								
								if ((response.getResponse() != null) && (!info.eof())) {
									client.get(new OID[] {
											new OID(info.getNextOID() + "." + ifId),
										}, thispnl, 
										new Object[] {
											info
										}, PDU.GET, null);
								}
								else if ((response.getResponse() != null) && (info.eof())) {
									updateUiValues();
								}
							}
						}
					}
					
					
				}
			}
		});
	}*/
	
	private void createCharts(JFreeChart chart,  TimeSeries ins, TimeSeries outs, String chartTitle, String yAxisName) {
		TimeSeriesCollection dataset = new TimeSeriesCollection();
		dataset.setDomainIsPointsInTime(true);
		Calendar cal = Calendar.getInstance();
		ins.add(
				new Second(cal.get(Calendar.SECOND),
						   cal.get(Calendar.MINUTE),
						   cal.get(Calendar.HOUR_OF_DAY),
						   cal.get(Calendar.DAY_OF_WEEK),
						   cal.get(Calendar.MONTH),
						   cal.get(Calendar.YEAR)), 0.0);
		outs.add(
				new Second(cal.get(Calendar.SECOND),
						   cal.get(Calendar.MINUTE),
						   cal.get(Calendar.HOUR_OF_DAY),
						   cal.get(Calendar.DAY_OF_WEEK),
						   cal.get(Calendar.MONTH),
						   cal.get(Calendar.YEAR)), 0.0);
		dataset.addSeries(ins);
		dataset.addSeries(outs);
        
        
		chart = ChartFactory.createTimeSeriesChart(
        		chartTitle,
                "Time", 
                yAxisName,
                dataset,
                true,
                true,
                false
            );
        
		chart.setBackgroundPaint(Color.white);

        final XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
        
        plot.setDomainCrosshairVisible(true);
        plot.setRangeCrosshairVisible(false);
        
        final XYItemRenderer renderer = plot.getRenderer();
        if (renderer instanceof StandardXYItemRenderer) {
			final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
			rr.setShapesFilled(true);
			renderer.setSeriesStroke(0, new BasicStroke(2.0f));
			renderer.setSeriesStroke(1, new BasicStroke(2.0f));
        }
        
        final DateAxis axis = (DateAxis) plot.getDomainAxis();
        axis.setDateFormatOverride(new SimpleDateFormat("hh:mm:ss"));
        
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(600, 270));
        chartPanel.setMouseZoomable(true, false);
        pnlCharts.setLayout(new BoxLayout(pnlCharts, BoxLayout.Y_AXIS));
        pnlCharts.add(chartPanel);
        chartPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        this.validate();
        //pnlTopChart.set setContentPane (chartPanel);
	}

	@Override
	public void valuesRetrieved(Object sender) {
		if ((infoDet != null) && (!infoDet.isInit())) {
			updateUiValues();
		}
	}
}
